package com.ftg.learn.rbac.controller;

import com.ftg.learn.rbac.entity.Role;
import com.ftg.learn.rbac.service.impl.RoleServiceImpl;
import com.ftg.learn.util.BaseController;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author kangjx
 * @since 2022-03-23
 */
@Api(tags = "角色管理列表")
@RestController
@RequestMapping("/rbac/role")
public class RoleController extends BaseController<Role, RoleServiceImpl> {


    @PutMapping("/updateIce/{id}/{num}")
    public boolean updateIce(@PathVariable("id") int id, @PathVariable("num") int num){
        return super.service.updateIce(id,num);
    }

    /**
     * 查询 当前用户具有哪些角色  对应页面当中右侧的框
     * @param uid 用户编号
     * @return
     */
    @GetMapping("/showRoleIdForUid/{uid}")
    public List<String>  showRoleIdForUid(@PathVariable("uid") String uid){
        return super.service.showRoleIdForUid(uid);
    }

    /**
     * 用户分组
     * @param uid
     * @param rids
     * @return
     */
    @PostMapping("/userForRole")
    public Boolean userForRole(@RequestParam("uid") int uid,@RequestParam("rids") List<String> rids){
        return super.service.userForRole(uid,rids);
    }

}
